#include "BankAccount.hh"
#include <iostream>
#include <sstream>
#include <iomanip>

namespace Bank {
// Constructor
    Account::Account(const std::string& id, const std::string& name, double initialBalance)
        : accountId(id), ownerName(name), balance(initialBalance) {}

    std::string Account::getAccountId() const {
        return accountId;
    }

    std::string Account::getOwnerName() const {
        return ownerName;
    }

    double Account::getBalance() const {
        return balance;
    }

    void Account::recordTransaction(const Transaction& transaction) {
        transactions.push_back(transaction);
    }

    const std::vector<Transaction>& Account::getTransactions() const {
        return transactions;
    }

    void Account::displayInfo() const {
        std::cout << "Account ID: " << accountId << "\n";
        std::cout << "Owner: " << ownerName << "\n";
        std::cout << "Balance: (CNY)" << std::fixed << std::setprecision(2) << balance << "\n";
    }

    std::string Account::generateReport() const {
        std::ostringstream report;
        for (const auto& tx : transactions) {
            report << tx.toString() << "\n";
        }
        return report.str();
    }
}
